use crate::schema;
use crate::models;
use diesel;
use diesel::*;
use diesel::{r2d2::ConnectionManager,
r2d2::PooledConnection,
MysqlConnection,
connection::SimpleConnection,
connection::Connection};

#[derive(Queryable)]
pub struct User {
    pub id:i32,
    pub name: String,
    pub age: i32,
    pub passwd: String,
}

type Conn = PooledConnection<ConnectionManager<MysqlConnection>>;

impl User {
    // add code here
    fn find_by_id(connection:&Conn,id:i32)->Vec<String>{
        use schema::users::dsl::*;
        let mut itm=users.select(name).load::<String>(connection).expect("worng");
        itm
    }
}